package com.thiswhyme.fsplus.utils;

import java.util.regex.Pattern;

/**
 * @description: 正则工具类
 * @author: thiswhyme
 * @date: 2021/4/30
 */
public class PatternUtils {

    /**
     * ip:port正则
     */
    private static final Pattern ipPortPattern = Pattern.compile("^(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]):([0-9]|[1-9]\\d|[1-9]\\d{2}|[1-9]\\d{3}|[1-5]\\d{4}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$");

    /**
     * 校验字符串是否ip:port
     * @param ipPort
     * @return
     */
    public static boolean isIpPort(String ipPort) {
        return ipPortPattern.matcher(ipPort).matches();
    }
}
